﻿namespace Agile.DataAccess
{
	internal abstract class BaseExistsBuilder
	{
		public BuilderData Data { get; set; }
		protected ActionsHandler Actions { get; set; }

        public BaseExistsBuilder(IDbCommand command, string name)
		{
			Data =  new BuilderData(command, name);
			Actions = new ActionsHandler(Data);
		}

        public bool Execute()
		{
            Data.Command.Script(Data.Command.Data.Context.Data.FluentDataProvider.GetSqlForExistsBuilder(Data));
            return Data.Command.QuerySingle<int>() > 0 ? true : false;
		}
	}
}
